//
//  ZCTableViewViewController.m
//  Unicom
//
//  Created by increase on 16/1/13.
//  Copyright © 2016年 increase. All rights reserved.
//

#import "ZCTableViewViewController.h"
#import "AFNetworkHandler.h"
#import "ZCRoomDetailViewController.h"

@interface ZCTableViewViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataArray;

@end

@implementation ZCTableViewViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self getTableViewData];
    [self createTableView];
    
}

#pragma mark - 获取数据
- (void)getTableViewData
{
    NSString *str1 = [NSString stringWithFormat:@"http://%@pdaGenerator!updateGenerator.interface", [[NSUserDefaults standardUserDefaults] objectForKey:@"url"]];
    
    NSLog(@"str1:%@", str1);
    
    NSString *str2 = [[NSUserDefaults standardUserDefaults] objectForKey:@"uid"];
    NSLog(@"%@", str2);
    NSString *bodyString = [NSString stringWithFormat:@"jsonRequest={\"generatorAddr\":\"\",\"generatorName\":\"\"}UID=%@", [[NSUserDefaults standardUserDefaults] objectForKey:@"uid"]];
    NSLog(@"%@", bodyString);
    
    
    NSData *bodyData = [bodyString dataUsingEncoding:NSUTF8StringEncoding];
    
    
    [AFNetworkHandler requestPOSTWithURL:str1 body:bodyData comletion:^(id result) {
        
        NSLog(@"%@", result[@"info"]);
    }];
}




#pragma mark - 创建tableView
- (void)createTableView
{
    self.tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.textLabel.text = @"1";
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    ZCRoomDetailViewController *roomVC = [[ZCRoomDetailViewController alloc] init];
    [self.navigationController pushViewController:roomVC animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
